/**
 * 定时器组件
 */
cc.Class({
    extends: cc.Component,

    properties: {
        target:{
            default:null,
            type:cc.Node,
        },
        delay:{
            default: 0.0,
            tooltip:'延时，0代表下一帧就执行'
        },
        scheduleEvents:{
            default:[],
            type:[cc.Component.EventHandler],
        },
        startOnLoad:{
            default: true,
            tooltip:'是否加载后就启动计时'
        }
    },

    onLoad(){
        if (this.target == null)
            this.target = this.node;
    },

    start(){
        this._scheduleHandler = this._schedule.bind(this);
        if (this.startOnLoad == true)
            this.startSchedule();
    },

    startSchedule(){
        this.scheduleOnce(this._scheduleHandler, this.delay);
    },

    _schedule() {
        var e = new cc.Event.EventCustom('geoScheduler');
        e.target = this.node;
        cc.Component.EventHandler.emitEvents(this.scheduleEvents, e);
    },

    TestFunc(a, b, c){
        cc.log('ok');
    }
});
